package com.xy.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.xy.dto.DocxContentDTO;
import jakarta.persistence.*;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.UpdateTimestamp;

import java.sql.Timestamp;

@Entity
@Data
@NoArgsConstructor
@DynamicUpdate
@DynamicInsert
@Table(name = "docx_content")
public class DocxContentEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    private String docContent;
    private int type;
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @CreationTimestamp
    private Timestamp insertDate;
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @UpdateTimestamp
    private Timestamp updateDate;

    public DocxContentEntity(DocxContentDTO docxContentDTO) {
        this.docContent = docxContentDTO.getDocContent();
        this.type = docxContentDTO.getType();
    }
}
